//
//  GLGWBaseViewModel.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/12.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "GLGWBaseViewModel.h"

@interface GLGWBaseViewModel ()
@property (nonatomic,strong) UIView * baseSuperView;
@property (nonatomic,strong) UIView * __nullable noDataView;

@end

@implementation GLGWBaseViewModel

-(instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView{
    if (self = [super init]) {
        self.baseSuperView = superView;
    }
    return self;
}

-(instancetype)initWithViewToViewScrollView:(UIScrollView *)scrollView theSuperView:(UIView *)superView{
    if (self = [super init]) {
        
    }
    return self;
}

-(instancetype)initWithViewToViewCollectionView:(UICollectionView *)collectionView theFlowLayout:(YLJCollectionViewFlowLayout *)flowlayout theSuperView:(UIView *)superView{
    if (self = [super init]) {
        
    }
    return self;
}

-(instancetype)initWithSuperView:(UIView *)superView{
    if (self = [super init]) {
        
    }
    return self;
}

-(void)showNoDataImageView:(UIView *)noDataView{
    if (!self.noDataView) {
        self.noDataView = [UIView new];
        [self.noDataView addSubview:noDataView];
        [self.baseSuperView.subviews enumerateObjectsUsingBlock:^(UITableView* obj, NSUInteger idx, BOOL *stop) {
            if ([obj isKindOfClass:[UITableView class]] || [obj isKindOfClass:[UICollectionView class]]) {
                [self.noDataView setFrame:CGRectMake(0, 0,obj.frame.size.width, obj.frame.size.height)];
                [obj addSubview:self.noDataView];
            }
        }];
    }
}

-(void)removeNoDataImage{
    if (self.noDataView) {
        [self.noDataView removeFromSuperview];
        self.noDataView = nil;
    }
}
@end
